Don't capture rustdoc output for transitive deps
authorAlex Crichton <alex@alexcrichton.com>
Tue, 8 Sep 2015 17:39:15 +0000 (10:39 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 8 Sep 2015 23:44:54 +0000 (16:44 -0700)
We already started doing this for the compiler awhile back, so this just brings
rustdoc up to the same parity

src/cargo/ops/cargo_rustc/mod.rs
tests/test_cargo_doc.rs

index ab0887864c9edeb3438d8db13060d7459da678d2..a13a74dc00fc21ae21d3e1c9da21e2280855cc9d 100644 (file)
@@ -8,7 +8,7 @@ use std::sync::Arc;
 
 use core::{SourceMap, Package, PackageId, PackageSet, Target, Resolve};
 use core::{Profile, Profiles};
-use util::{self, CargoResult, human, caused_human};
+use util::{self, CargoResult, human};
 use util::{Config, internal, ChainError, Fresh, profile, join_paths};
 
 use self::job::{Job, Work};
@@ -533,31 +533,15 @@ fn rustdoc(package: &Package, target: &Target, profile: &Profile,
 
     trace!("commands={}", rustdoc);
 
-    let primary = package.package_id() == cx.resolve.root();
     let name = package.name().to_string();
     let desc = rustdoc.to_string();
     let exec_engine = cx.exec_engine.clone();
 
     Ok(Work::new(move |desc_tx| {
         desc_tx.send(desc).unwrap();
-        if primary {
-            try!(exec_engine.exec(rustdoc).chain_error(|| {
-                human(format!("Could not document `{}`.", name))
-            }))
-        } else {
-            try!(exec_engine.exec_with_output(rustdoc).and(Ok(())).map_err(|err| {
-                match err.exit {
-                    Some(..) => {
-                        caused_human(format!("Could not document `{}`.",
-                                             name), err)
-                    }
-                    None => {
-                        caused_human("Failed to run rustdoc", err)
-                    }
-                }
-            }))
-        }
-        Ok(())
+        exec_engine.exec(rustdoc).chain_error(|| {
+            human(format!("Could not document `{}`.", name))
+        })
     }))
 }
 
index 6def20ba21d4ffbe2d7f4331dae0ba7f20775564..57d37129d6ce32218bb78c4b1a645fdd14acda3c 100644 (file)
@@ -1,3 +1,5 @@
+use std::str;
+
 use support::{project, execs, path2url};
 use support::{COMPILING, RUNNING};
 use hamcrest::{assert_that, existing_file, existing_dir, is_not};
@@ -314,6 +316,38 @@ test!(target_specific_not_documented {
                 execs().with_status(0));
 });
 
+test!(output_not_captured {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [package]
+            name = "foo"
+            version = "0.0.1"
+            authors = []
+
+            [dependencies]
+            a = { path = "a" }
+        "#)
+        .file("src/lib.rs", "")
+        .file("a/Cargo.toml", r#"
+            [package]
+            name = "a"
+            version = "0.0.1"
+            authors = []
+        "#)
+        .file("a/src/lib.rs", "
+            /// ```
+            /// ☃
+            /// ```
+            pub fn foo() {}
+        ");
+
+    let output = p.cargo_process("doc").exec_with_output().err().unwrap()
+                                                          .output.unwrap();
+    let stderr = str::from_utf8(&output.stderr).unwrap();
+    assert!(stderr.contains("☃"), "no snowman\n{}", stderr);
+    assert!(stderr.contains("unknown start of token"), "no message\n{}", stderr);
+});
+
 test!(target_specific_documented {
     let p = project("foo")
         .file("Cargo.toml", &format!(r#"